package com.szzg10.pattern.command;

import com.szzg10.pattern.command.Fan.LEVEL;

public class FanLowCommand implements Command {

	private Fan fan;
	private LEVEL pre;
	
	public FanLowCommand(Fan fan) {
		this.fan = fan;
	}
	
	@Override
	public void execute() {
		pre = fan.getLevel();
		fan.low();
	}

	@Override
	public void undo() {
		if(pre == LEVEL.HIGH) {
			fan.high();
		}
		else if(pre == LEVEL.MEDIUM) {
			fan.medium();
		}
		else if(pre == LEVEL.LOW) {
			fan.low();
		}
		
	}
}
